package com.zhz.mall.portal.modules.sms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhz.mall.portal.enums.SmsHomeAdvertiseStatusEnum;
import com.zhz.mall.portal.enums.SmsHomeAdvertiseTypeEnum;
import com.zhz.mall.portal.modules.sms.mapper.SmsHomeAdvertiseMapper;
import com.zhz.mall.portal.modules.sms.model.SmsHomeAdvertise;
import com.zhz.mall.portal.modules.sms.service.SmsHomeAdvertiseService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页轮播广告表 服务实现类
 * </p>
 *
 * @author zhouhengzhe
 * @since 2023-02-04
 */
@Service
public class SmsHomeAdvertiseServiceImpl extends ServiceImpl<SmsHomeAdvertiseMapper, SmsHomeAdvertise> implements SmsHomeAdvertiseService {

    /**
     * 获取首页轮播图信息
     *
     * @return
     */
    @Override
    public List<SmsHomeAdvertise> getHomeBanners() {
        QueryWrapper<SmsHomeAdvertise> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(SmsHomeAdvertise::getType, SmsHomeAdvertiseTypeEnum.SHUFFLING_LOCATION_PC.getCode())
                .eq(SmsHomeAdvertise::getStatus, SmsHomeAdvertiseStatusEnum.ONLINE.getCode())
                .orderByAsc(SmsHomeAdvertise::getSort);
        return this.list(queryWrapper);
    }
}
